package com.scrx.ymg.dao.entrepot;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.scrx.ymg.dao.base.BaseDaoImpl;
import com.scrx.ymg.entity.ProductEvaluate;
import com.scrx.ymg.entity.SuperMarketEntrepot;

@Repository("SuperMarketEntrepotDao")
public class SuperMarketEntrepotDaoImpl extends BaseDaoImpl implements ISuperMarketEntrepotDao {
	
	public List<SuperMarketEntrepot> getEntrepotByID(String id) {
		Query query=getCurrentSession().createQuery("from SuperMarketEntrepot where superId=:id and recommend=1 and hot=0 and putaway=1 order by recommendTime desc");
		query.setParameter("id",Integer.parseInt(id));
		return (List<SuperMarketEntrepot>)query.list();
	}
	
	public List<SuperMarketEntrepot> getHotBySuperId(String id,int hot){
		Query query=getCurrentSession().createQuery("from SuperMarketEntrepot where superId=:id and hot=:hot and putaway=1");
		query.setParameter("id",Integer.parseInt(id));
		query.setParameter("hot", hot);
		return (List<SuperMarketEntrepot>)query.list();
	}


	public SuperMarketEntrepot getEntrepotByEntID(String id) {
		Query query=getCurrentSession().createQuery("from SuperMarketEntrepot where id=:id");
		query.setParameter("id",Integer.parseInt(id));
		SuperMarketEntrepot superme=null;
		if(query.list().size()>0){
			superme=(SuperMarketEntrepot)query.list().get(0);
		}
		return superme;
	}


	public List<ProductEvaluate> getProductEvaluateByIdAndType(int productId, int typeId) {
		Query query=getCurrentSession().createQuery("from ProductEvaluate where productId=:productId and typeId=:typeId");
		query.setParameter("productId",productId);
		query.setParameter("typeId", typeId);
		return (List<ProductEvaluate>)query.list();
	}



}
